package com.thekernel.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.thekernel.dao.AdminDao;
import com.thekernel.entity.Admin;
import com.thekernel.utils.MybatisUtil;

public class AdminDaoMybatisImpl implements AdminDao{

	@Override
	public int insertAdmin(Admin admin) {
		 			
		SqlSessionFactory factory = MybatisUtil.createFactory();
		SqlSession sqlSession = factory.openSession();

		int result = sqlSession.insert("Admin.insertAdmin", admin);		
		sqlSession.commit();

		return result;
	}

	@Override
	public Admin selectByUsername(String username) {
			
		SqlSessionFactory factory = MybatisUtil.createFactory();
		SqlSession sqlSession = factory.openSession();
		
		Admin admin = sqlSession.selectOne("Admin.selectByUsername", username);

		return admin;
	}

	@Override
	public int deleteById(int adminid) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateAdmin(Admin admin) {
		// TODO Auto-generated method stub
		return 0;
	}

}
